Show Output of JavaScript Code

Author: Al-mamun Sarkar Date: 2021-03-29 16:00:49

There are four-way for showing the output of JavaScript codes. Each one has a different use case. Showing output systems are as follows. 

innerHTML: For show output inside HTML tag.

document.write(): Display Output Into HTML.

alert(): Show alert box.

console.log(): Showing Output in the browser console. 

 

Example:

<!DOCTYPE html>
<html>
<head>
	<title> Displaying Output </title>
</head>
<body>

<h2>Show Ouput</h2>
<p id="myId"></p>

<script>
	document.write("Write Output on the document");
  	document.getElementById("myId").innerHTML = "This is JavaScript Example";
  	console.log("Show Output on Brawser console");
  	alert("This is an alert");
</script>

</body>
</html>